<template>
  <div class="son">
    <div>从父组件获取零花钱: {{ pinMoney }}</div>
    <button @click="mittEmit('toy', '蜡笔小新')">发送玩具信息</button>
  </div>
</template>

<script setup lang="ts">
import { onUnmounted, ref } from "vue";
import { mittEmit, mittOn, mittOff } from "../../utils/emitter";

const pinMoney = ref(0);
mittOn("count", (v: number) => {
  pinMoney.value = v;
});

onUnmounted(() => {
  mittOff("count");
});
</script>

<style scoped>
@import "../common.css";
</style>
